import React, { PureComponent } from 'react';

// 为Home 和About组件 新增一个区域props
// 定义一个高阶组件
function enhanceRegionProps(WrappedComponent) {
  return props => {
    return <WrappedComponent {...props} region= "中国"/>
  }
}

class Home extends PureComponent {
  render() {
    return <h2>Home：{`昵称：${this.props.nickname},等级：${this.props.level},区域：${this.props.region}`}</h2>
  }
}

class About extends PureComponent {
  render() {
    return <h2>About：{`昵称：${this.props.nickname},等级：${this.props.level},区域：${this.props.region}`}</h2>
  }
}
const EnhanceRegHome = enhanceRegionProps(Home)
const EnhanceRegAbout = enhanceRegionProps(About)
class App extends PureComponent {
  render() {
    return (
      <div>
        <EnhanceRegHome nickname="小明" level={99}/>
        <EnhanceRegAbout nickname="小红" level={1}/>
      </div>
    );
  }
}



export default App;